define("pages/jls_sj/zcrs_main", [
        "../../common/componts.js",
        "../../plugins/easyui/jquery-easyui-1.5.1/jquery.easyui.min",
        "../../plugins/easyui/jquery-easyui-1.5.1/easyloader",
        "../../plugins/artTemplate/artTemplate"
    ],
    function(require) {
        var comonts=require("../../common/componts");
        var queryTableId="awdQueryTableId";
        var selectid;
        var id;
        //comonts.initSelectPage(undefined);
        //comonts.initSelect(undefined,undefined,undefined);
        var tableInit=function(){
            comonts.initTable(queryTableId,{
                url:"",
                title:'',
                fit:true,
                width:'100%',
                tools:'#ywtzyc',
                columns :  [
                    {
                        field: 'oid',
                        title: '序号',
                        formatter: function(value, rowData, rowIndex){
                            return '<input type="radio" name="ryRadio" id="ryRadio' + rowIndex + '" value="' + rowData.oid + '" />';
                        }},
                    {field : 'rssj',width : 150,title:'入所时间',sortable:'true',formatter: function(value,row,index){return '<span title='+value+'>'+value+'</span>'}},
                    {field : 'xm',title : '姓名',width : 80,sortable:'true',formatter: function(value,row,index){return '<span title='+(row.xm==null?"":row.xm)+'>'+(row.xm==null?"":row.xm)+'</span>'}},
                    {field : 'xb',title : '性别',width : 150,sortable:'true',formatter: function(value,row,index){return '<span title='+(row.bm==null?"":row.bm)+'>'+(row.bm==null?"":row.bm)+'</span>'}},
                    {field : 'csrq',title : '出生日期',width : 150,sortable:'true',formatter: function(value,row,index){return '<span title='+value+'>'+value+'</span>'}},
                    {field : 'mz',title : '民族',width : 150,sortable:'true',formatter: function(value,row,index){return '<span title='+value+'>'+value+'</span>'}},
                    {field : 'whcd',title : '文化程度',width : 150,sortable:'true',formatter: function(value,row,index){return '<span title='+(row.bahjString==null?"":row.bahjString)+'>'+(row.bahjString==null?"":row.bahjString)+'</span>'}},
                    {field : 'zy',title : '职业',width : 150,sortable:'true',formatter: function(value,row,index){return '<span title='+(row.rsrq==null?"":row.rsrq)+'>'+(row.rsrq==null?"":row.rsrq)+'</span>'}},
                    {field : 'xjdz',title : '现居住地',width : 150,sortable:'true',formatter: function(value,row,index){return '<span title='+(row.rsrq==null?"":row.rsrq)+'>'+(row.rsrq==null?"":row.rsrq)+'</span>'}},
                    {field : 'ab',title : '案别',width : 150,sortable:'true',formatter: function(value,row,index){return '<span title='+value+'>'+value+'</span>'}},
                    {field : 'jlqx',title : '拘留期限(日)',width : 150,sortable:'true',formatter: function(value,row,index){return '<span title='+value+'>'+value+'</span>'}},
                    {field : 'sadw',title : '送案单位',width : 150,sortable:'true',formatter: function(value,row,index){return '<span title='+value+'>'+value+'</span>'}},
                    {field : 'csrq',title : '出所日期',width : 150,sortable:'true',formatter: function(value,row,index){return '<span title='+value+'>'+value+'</span>'}},
                    {field : 'csyy',title : '出所原因',width : 150,sortable:'true',formatter: function(value,row,index){return '<span title='+value+'>'+value+'</span>'}},
                    {field : 'bz',title : '备注',width : 150,sortable:'true',formatter: function(value,row,index){return '<span title='+value+'>'+value+'</span>'}},
                    {field:'operate',title:'详细信息',align:'center',width : 60,/*width:$(this).width()*0.15,*/
                        formatter:function(value, row, index){
                            var str = '<a href="#" data-target="#ckPhoto" value="'+index+'" name="opera" data-toggle="modal" class="easyui-linkbutton"><img src="../../img/xq.png"></a>';
                            return str;
                            //return  '<button id="sh_add" onclick="add"  > 不通过</button>'
                        }
                    }
                ] ,
                //基本信息双击事件
                onDblClickRow:function(rowIndex, rowData){
                    $("input[name='ryRadio']")[rowIndex].checked = true;
                    $("#"+queryTableId).datagrid("selectRow", rowIndex);
                    selectid=rowData.id;
                },
                onLoadSuccess:function(data){
                    if(data.total>0){
                        $('#'+queryTableId).datagrid("selectRow", 0);
                        $("input[name='ryRadio']")[0].checked = true;
                    }
                    $("a[name='opera']").each(function(){
                        $(this).on('click',function () {
                            var index = $(this).attr('value');
                            var jbxx = data.rows[index];
                            kss.initJbxxxx(jbxx.gcbh,jbxx.rybh,jbxx.xm+"--详细信息");
                        });
                    });
                },
                //单击行选中取消事件
                onClickRow:function(rowIndex, rowData){
                    if(selectid!=rowData.id){
                        $("input[name='ryRadio']")[rowIndex].checked = true;
                        selectid=rowData.id;
                    }else{
                        $("#"+queryTableId).datagrid("unselectRow",rowIndex);
                        $("input[name='ryRadio']")[rowIndex].checked = false;
                        $('#'+queryTableId).datagrid('clearSelections');
                        selectid="";
                    }
                },
                onSelect:function(rowIndex, rowData){
                },
                rightmenu:function(){
                }
            });
            //页面高度自适应
            $('#'+queryTableId).datagrid('resize',{
                height:($(window).height()-150)
            });
        };

        var findJbxx=function(){
            var xm = $("#tz_xm").text('getValue');
            $('#'+queryTableId).datagrid('clearSelections');
            $('#'+queryTableId).datagrid('load',{'state':'R8'});
        }

        var bindAction2=function(){
            $("#wsbd_query").on("click",function(){
                findJbxx();
            });

            $(window).keydown(function(event) {
                if (event.keyCode == 13) {
                    findJbxx();
                }
            });

            $("#dy").click(function(){
                $('#dywin').window('open');
            });

        };

        /**
         * 画流程图
         */
        var drawGraph = function(){
            var user_permission = 2 ; 	//设置获取到的用户权限
            var rsdj_permission = 2 ;	//设置出所管理需要的权限
            var container = document.getElementById("main");
            var graph = new mxGraph(container);
            var parent = graph.getDefaultParent();

            graph.setHtmlLabels(true);
            graph.setEnabled(false);

            var style = {};

            style = graph.getStylesheet().getDefaultEdgeStyle();//圆角连线
            style[mxConstants.STYLE_ROUNDED] = true;//圆角连线
            style = mxUtils.clone(style);
            style[mxConstants.STYLE_SHAPE] = mxConstants.SHAPE_LABEL;  // 不设置这个属性 背景图片不出来

            style[mxConstants.STYLE_STROKECOLOR] = '#f5f5f5';

            style[mxConstants.STYLE_FILLCOLOR] = '#f5f5f5';

            style[mxConstants.STYLE_FONTCOLOR] = 'black';

            style[mxConstants.STYLE_ALIGN] = mxConstants.ALIGN_CENTER;

            style[mxConstants.STYLE_VERTICAL_ALIGN] = mxConstants.ALIGN_BOTTOM;

            style[mxConstants.STYLE_FONTSIZE] = 13;

            style[mxConstants.STYLE_IMAGE_ALIGN] = 0;

            style[mxConstants.STYLE_IMAGE_VERTICAL_ALIGN] = 0;

            style[mxConstants.STYLE_IMAGE] = '../../img/lcttx.png';

            style[mxConstants.STYLE_IMAGE_WIDTH] = 80;

            style[mxConstants.STYLE_IMAGE_HEIGHT] = 80;

            style[mxConstants.STYLE_SPACING_TOP] = 30;

            style[mxConstants.STYLE_SPACING] = 0.5;

            graph.getStylesheet().putCellStyle("style1", style);

            var style2 = {};

            style2 = graph.getStylesheet().getDefaultEdgeStyle();//圆角连线
            style2[mxConstants.STYLE_ROUNDED] = true;//圆角连线
            style2 = mxUtils.clone(style);
            style2[mxConstants.STYLE_SHAPE] = mxConstants.SHAPE_LABEL;  // 不设置这个属性 背景图片不出来

            style2[mxConstants.STYLE_STROKECOLOR] = '#f5f5f5';

            style2[mxConstants.STYLE_FILLCOLOR] = '#f5f5f5';

            style2[mxConstants.STYLE_FONTCOLOR] = 'black';

            style2[mxConstants.STYLE_ALIGN] = mxConstants.ALIGN_CENTER;

            style2[mxConstants.STYLE_VERTICAL_ALIGN] = mxConstants.ALIGN_BOTTOM;

            style2[mxConstants.STYLE_FONTSIZE] = 13;

            style2[mxConstants.STYLE_IMAGE_ALIGN] = 0;

            style2[mxConstants.STYLE_IMAGE_VERTICAL_ALIGN] = 0;

            style2[mxConstants.STYLE_IMAGE] = '../../img/zh.png';

            style2[mxConstants.STYLE_IMAGE_WIDTH] = 80;

            style2[mxConstants.STYLE_IMAGE_HEIGHT] = 80;

            style2[mxConstants.STYLE_SPACING_TOP] = 30;

            style2[mxConstants.STYLE_SPACING] = 0.5;

            graph.getStylesheet().putCellStyle("style2", style2);

            //获取流程节点的待办数量
            var jbdjCount=0;
            var jbqrCount=0;

            // 画人物
            var v1 = graph.insertVertex(parent, 'jypz', '检验凭证<font color="jbdj"></font>', 200, 150, 100, 105, "style2");
            var v2 = graph.insertVertex(parent, 'ksrs', '快速入所<font color="jbqr"></font>', 200, 20, 100, 105, "style1");

            var v3 = graph.insertVertex(parent, 'jydj', '简要登记<font color="jbqr"></font>', 400, 150, 100, 105, "style1");

            var v4 = graph.insertVertex(parent, 'jkjc', '健康检查<font color="jbqr"></font>', 600, 150, 100, 105, "style1");
            var v5 = graph.insertVertex(parent, 'ldsp', '领导审批<font color="jbqr"></font>', 600, 390, 100, 105, "style2");

            var v6 = graph.insertVertex(parent, 'fwdj', '附物登记<font color="jbqr"></font>', 800, 20, 100, 105, "style1");
            var v7 = graph.insertVertex(parent, 'rsdj', '入所登记<font color="jbqr"></font>', 800, 260, 100, 105, "style2");
            var v8 = graph.insertVertex(parent, 'lxcl', '另行处理<font color="jbqr"></font>', 800, 390, 100, 105, "style2");

            var v9 = graph.insertVertex(parent, 'kzhdrjs', '告知后带入拘室<font color="jbqr"></font>', 1000, 150, 100, 105, "style2");

            // 连线
            graph.insertEdge(parent, null, '',v1, v2 , "edgeStyle=elbowEdgeStyle;");
            graph.insertEdge(parent, null, '',v1, v3 , "edgeStyle=elbowEdgeStyle;");
            graph.insertEdge(parent, null, '',v3, v4 , "edgeStyle=elbowEdgeStyle;");
            graph.insertEdge(parent, null, '',v4, v5 , "edgeStyle=elbowEdgeStyle;");
            graph.insertEdge(parent, null, '',v4, v6 , "edgeStyle=elbowEdgeStyle;");
            graph.insertEdge(parent, null, '',v4, v7 , "edgeStyle=elbowEdgeStyle;");
            graph.insertEdge(parent, null, '',v5, v7 , "edgeStyle=elbowEdgeStyle;");
            graph.insertEdge(parent, null, '',v5, v8 , "edgeStyle=elbowEdgeStyle;");
            graph.insertEdge(parent, null, '',v6, v9 , "edgeStyle=elbowEdgeStyle;");
            graph.insertEdge(parent, null, '',v7, v9 , "edgeStyle=elbowEdgeStyle;");

            //添加事件
            graph.addListener(mxEvent.CLICK, function(sender, evt) {
                var cell11 = evt.getProperty('cell');
                //graph.setCellStyles(fillColor,black);
                if(cell11==null){
                    $("#pictureId").css({"display":"none"});
                    return ;
                }else if(cell11.id=='jypz'){
                    window.location.href='';
                }else if (cell11.id=='ksrs'){
                    window.location.href="/jls_sj/ksrs.html";
                }else if(cell11.id=='jydj'){
                    window.location.href="/jls_sj/jydj.html";

                }else if(cell11.id=='fwdj'){
                    window.location.href="/jls_fwdj/fwdj.html";

                }else if (cell11.id == 'jkjc') {
                    window.location.href='/jls_sj/jkjc.html'
                }
            });
            //鼠标悬浮效果
            var track = new mxCellTracker(graph);
            var self = this;
            track.mouseMove = function(sender, me) {
                var cell1 = this.getCell(me);
                if(cell1==null){
                    $("#pictureId").css({"display":"none"});
                    return ;
                }else{
                    if(cell1.id=="tscldj"){
                        $("#pictureId").css({"display":"block","left":"250px","top":"170px"});
                        $("#pictureId").html("投诉处理登记登记！");
                    }else if (cell1.id=="ldsp"){
                        $("#pictureId").css({"display":"block","left":"550px","top":"170px"});
                        $("#pictureId").html("领导审批！");
                    }else if (cell1.id=="cldjcljg"){
                        $("#pictureId").css({"display":"block","left":"850px","top":"170px"});
                        $("#pictureId").html("登记处理结果！");
                    }
                }
            };
            //
            function bodyScale(){
                var main = document.getElementById("main"); //获取id="main"
                var devicewidth=document.documentElement.clientWidth;
                var scale=devicewidth/1275;//除去当前流量器分辨率1275
                main.style.zoom=scale;//zoom是设置或检索对象的缩放比例.
            }
            window.onload=window.onresize=function(){
                bodyScale();
            }
            //自适应任何设备屏幕
            function bodyScale(){
                var main = document.getElementById("main"); //获取id="main"
                var devicewidth=document.documentElement.clientWidth;
                var scale=devicewidth/1275;//除去当前流量器分辨率1275
                main.style.zoom=scale;//zoom是设置或检索对象的缩放比例.
            }
            window.onload=window.onresize=function(){
                bodyScale();
            }
        }

        var initView=function(){
            console.info("进入rsdj的sea.js");
            drawGraph();
            tableInit();
            bindAction2();
        }
        initView();
    });
